package com.motus.pm.daoImpl;


import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.motus.pm.dao.PhaseInfoDao;
import com.motus.pm.vo.PmPhaseInfo;

@Repository
public class PhaseInfoDaoImpl extends BaseDaoImpl<PmPhaseInfo> implements PhaseInfoDao {
	
	@Autowired
	private SessionFactory sessionFactory;

	@SuppressWarnings("unchecked")
	@Override
	public List<PmPhaseInfo> getPhaseInfosByDeptIdAndPid(int deptId, String pid) {
		Session session =sessionFactory.getCurrentSession();
		String sql="select * from pm_phase_info where phase_id in"+
				"(select phase_id from pm_project_phase where pid=? and phase_id in"+
				"(select phase_id from pm_phase_info where depart_id=?))";
		Query query=session.createSQLQuery(sql).addEntity(PmPhaseInfo.class);
		query.setString(0, pid);
		query.setInteger(1, deptId);
		return query.list();
	}

	

}
